Shortest path search method &#34;Midway&#34;

ABSTRACT

“Midway” is a new method to search for a shortest path from a single source node to a single destination node in a two dimensional computer network. It is similar to Dijkstra shortest path search algorithm in the way to build a shortest path tree, but it is different from Dijkstra algorithm in the following points. Instead of starting from the source node and searching all the way through to the destination node as what Dijkstra algorithm does, Midway runs shortest path search from both ends (i.e. source and destination) simultaneously or alternatively, until a shortest path from one end meets a shortest path from the other end on midway. Algorithms are designed to run shortest path search from both ends, and conditions other than those used by Dijkstra are defined to determine when the search should terminate. It has been verified that the new search method takes much less overhead and time than Dijkstra to find a shortest path.

BACKGROUND OF INVENTION

[0001] 1. Field of Invention

[0002] The said invention is applied to searching for a shortest pathfrom a single source node to a single destination node in a flatcomputer network. The shortest path search function which implementsthis new method is used by the routing module running in a router of apacket (or cell) switching network or running in a switching node of acircuit switching network.

[0003] 2. Description of the Related Art

[0004] A flat computer network (or each flat layer of a hierarchicalnetwork) consists of multiple number of nodes (i.e. dedicated purposecomputers) connected by communication links (wired or wireless), andforms a certain two dimensional topology. Each communication link isassigned a cost which is determined by considerations of applicationrequirements [1]. When a packet (or cell) is to be sent or a circuit isto be built from a source node to a destination node in a network, it isrequired to find a shortest path among all available paths between thesource and the destination. If all links in a network are assigned thesame cost, the shortest path is a minimum hop path. If link costs aredifferent, the shortest path is a minimum cost path. In the latter casethe number of hops in a minimum cost path may exceed that in a minimumhop path.

[0005] The most popular method used by the current art to search for ashortest path is Dijkstra algorithm which may be a classic Dijkstraalgorithm or an improved version of Dijkstra algorithm. Dijkstraalgorithm has been described in many literatures [1] [3], and may beapplied in two different cases.

[0006] 1. To find shortest paths from a single source node to all othernodes in a network. Dijkstra algorithm makes a flood search and builds ashortest path tree with the source node as its root, and with all othernodes in the network as branch nodes or leave nodes of the tree. Thesearch will terminate when all nodes in the network are linked up to thetree. The time complexity of Dijkstra algorithm in case 1 is O(P_(N) ²)where P_(N) is the total number of nodes in the network [4]. Dijkstraalgorithm is efficient enough when applied in this case.

[0007] 2. To find a shortest path from a single source node to a singledestination node in a network. Dijkstra algorithm works in the same wayas it does in case 1, but the search will terminate when the destinationnode is attached to the tree. In this case Dijkstra algorithm alsobuilds a shortest path tree with the source node as its root and asubset of the nodes in the network as branch nodes or leave nodes of thetree. The destination node is the last leave node being attached to thetree. In the case of searching for a minimum hop path this algorithmcreates a minimum hop path tree. In the worst luck case it has to findall the minimum hop paths to all the nodes which are as far away as orless far away than the destination node from the source node (i.e. allthe nodes lying in the searching range shown by the big circle indrawing sheet 1-1), even though it is only required to find one path toa single destination node. In the case of searching for a minimum costpath this algorithm builds a minimum cost path tree. In the worst luckcase it has to find all the minimum cost paths from the source to allthe nodes which are at the same cost away as or less cost away than thedestination node from the source node (i.e. all the nodes lying in thebig searching range circle shown by drawing sheet 1-1). In other wordsthe problem of finding a shortest path (minimum hop or minimum costpath) from a single source to a single destination by Dijkstra algorithmis equivalent to the problem of finding all shortest paths from a singlesource node to all the nodes in a sub-network lying within the boundaryof the big circle in sheet 1-1. The center of the big circle is thesource node and the radius is the number of hops or the cost of the pathfrom the source to the destination. Bear in mind that sheet 1-1 is atopology map rather than a geographic map. All hops or all equal costpaths are displayed by equal length straight lines, although they arenot equal in length geographically. Hence, all nodes which are at thesame hops away or at the same path cost away from the source node lie onthe circumference of a circle. The time complexity of Dijkstra algorithmin case 2 is O(P_(D) ²) where P_(D) is the total number of nodes in thesub-network which includes all nodes in the big circle shown by sheet1-1 [4].

[0008] Obviously Dijkstra algorithm is not efficient enough in case 2,as it has to find a large number of shortest paths which are notrequired while the purpose is to find only one shortest path from asingle source to a single destination.

[0009] In a large high speed network the set up time of a shortest pathfrom a single source to a single destination is a very importantparameter, especially from the point of view of path switching onfailure or preemption. The rerouting of a lot of connections that wereusing a failing link or node may lead to a high number of simultaneousnew path set up and create a burst of processing overhead. In order toavoid disrupting the connections at the end user level in the abovesituation it is highly desirable to reduce both the overhead of ashortest path search algorithm and the shortest path set up time.

SUMMARY OF THE INVENTION

[0010] To make shortest path search more efficient and faster, a newsearch method “Midway” is invented. Instead of starting from the sourcenode and searching all the way through to the destination node as theway Dijkstra algorithm works, Midway starts from both ends (i.e. sourceand destination) and runs shortest path search from both endssimultaneously or alternatively, until a shortest path from one endmeets a shortest path from the other end on midway at a “meet node” (seesheet 1-1). Hence the new algorithm is named “Midway”. In comparisonwith Dijkstra, Midway algorithm drastically reduces the overhead insearch of a shortest path by reducing the number of nodes beingsearched, and hence it can find a shortest path in much less time. Inmultiprocessor environment the two shortest path search processes (orthreads) from both ends may run in parallel, and shortest path set uptime will be further reduced. The implementation of the said new searchmethod should minimize the additional code overhead required by doingshortest path search simultaneously or alternatively from both ends, andshould define a new way other than the way used by Dijkstra to determinewhen the search should terminate. The implementation will be describedin the detailed description part.

BRIEF DESCRIPTION OF THE DRAWING

[0011] Drawing sheet 1-1 shows a big circle which is the searching rangeof Dijkstra algorithm applied to searching for a shortest path from asingle source node to a single destination node. It also shows two smallcircles which are searching ranges of Midway algorithm. One is thesearching range of the search started from the source node while theother is that of the search started from the destination node. The twosmall circles touch at the meet node where two shortest paths meet.

DETAILED DESCRIPTION OF THE INVENTION Comparison of Overhead betweenMidway and Dijkstra Algorithms

[0012] The Dijkstra algorithm overhead is measured by O(P_(D) ²) whereP_(D) is the number of nodes in the searching range shown by a bigcircle in sheet 1-1, while the Midway algorithm overhead is measured byO(P_(M1) ²) plus O(P_(M2) ²) where P_(M1) is the number of nodes insmall searching range circle 1 and P_(M2) is the number of nodes insmall circle 2 (sheet 1-1). The number of nodes contained in a searchingrange circle depends on the radius of the circle and topology of thenetwork, and it grows rapidly with the radius (i.e. total number of hopsor total path cost of the shortest path). It can be shown heuristicallyby calculating the values of P_(M1), P_(M2) and P_(D) for some specialnetwork topology cases that Midway algorithm saves a significant amountof overhead by reducing the number of nodes being searched, since Midwaycuts the radius of the searching range circle into half while thenetwork topology being the same. This conclusion is also supported bysimulation test results of the code implementing Midway algorithm.

Detailed Description of Midway Algorithm Implementation

[0013] Midway shortest path search algorithm may be implemented indifferent ways. In single processor environment shortest path searchfrom both end nodes is executed in a single task and a single functionby alternatively swapping pointers to two separate set of datastructures, one for search from source node and the other for searchfrom destination node. In multiprocessor environment path searchprocesses from source node and from destination node may be executed inparallel to further reduce shortest path set up time. In comparison toDijkstra algorithm Midway requires some additional code overhead as itneeds to do shortest path search from both source and destination nodes.In order to avoid the additional overhead from outweighing the benefitMidway algorithm provides, the implementation should minimize the abovementioned code overhead. Detailed description of Midway algorithm isgiven in two parts one for minimum cost path search and the other forminimum hop path search, and each algorithm is further divided into twoseparate cases, one for single processor environment and the other formulti-processor environment. The description illustrates how to dominimum cost or minimum hop search from both the source node anddestination node simultaneously by multi-threading or multi-tasking, oralternatively in a single task and a single function, and how todetermine a shortest path is found successfully or the path searchfails. This also illustrates the essential difference between Dijkstraand Midway algorithms.

[0014] All sanity checks, check of link capabilities and other linkparameters against path requirements, randomizing the order of nodes tobe searched for link load balancing purpose, and other considerationsrequired in practical application are omitted for clarity purpose.

[0015] Assumptions made:

[0016] 1. The network is an undirected graph which means that if a linkcost is assigned to a link between two nodes, the cost is same in bothdirections.

[0017] 2. Link cost is always a positive value.

[0018] 3. Valid node numbers are 1,2,3, . . . , MAXNODES.

[0019] Definitions:

[0020] In order to make the description of the algorithm more readablethe following terms are defined. (words in Italic font are definedterms):

[0021] Network topology map—an array (struct nodeInfonetMap[MAXNODES+1]) wherein MAXNODES equals to total number of nodes inthe network, and its indexes are node numbers of nodes in the network(see header file midway.h). Each array element is a structure (structnodeInfo) which contains two fields, number of neighbor nodes and a listof neighbor nodes. Each element of neighbor node list (structneighborNode) contains fields of neighbor node number and link cost. (Itmay also contain fields of link capabilities, link block or other linkparameters which may be required in practical application, but they arenot included here.) The network topology map structure should be updatedby routing module.

[0022] Shortest path—a minimum cost path or a minimum hop path as thecase may be.

[0023] Forward search direction—search started from source node.

[0024] Backward search direction—search started from destination node.

[0025] Forward search tree—a shortest path search tree with source nodeas its root.

[0026] Backward search tree—a shortest path search tree with destinationnode as its root.

[0027] Current search direction tree—if current search direction isforward, it is forward search tree, otherwise it is backward searchtree.

[0028] Opposite search direction tree—if current search direction isforward, it is backward search tree, otherwise it is forward searchtree.

[0029] Searching node—a node from which to search for a shortest path bylooking at all its neighbor nodes.

[0030] Neighbor node—a node which has a direct link to a searching node.

[0031] Node path cost—the total cost of the links in the path whichconnects this node to the root of the tree. (for minimum cost path only)

[0032] Node path hops—the total number of hops in the path whichconnects this node to the root of the tree.

[0033] Total path cost—the total cost of the links in a path whichconnects the source node to the destination node. (for minimum cost pathonly).

[0034] Total path hops—the total number of hops in a path which connectsthe source node to the destination node.

[0035] Path cost—may be used to denote node path cost or total path costaccording to the context.

[0036] Path hops—may be used to denote node path hops or total path hopsaccording to the context.

[0037] Path parameters—embodies path cost and path hops.

[0038] Path A is more expensive than path B—if path cost of A is greaterthan path cost of B or if path hops of A is greater than path hops of Bwhen the two path costs are equal. (for minimum cost path only).

[0039] Path A is less expensive than path B—if path cost of A is lessthan path cost of B or if path hops of A is less than path hops of Bwhen the two path costs are equal. (for minimum cost path only).

[0040] Path A is equally expensive as path B—if path cost of A is equalto path cost of B and path hops of A is equal to path hops of B. (forminimum cost path only).

[0041] Least cost leave node is a leave node whose path to the root nodeis not more expensive than the path of any other leave node to the root.(for minimum cost path only).

[0042] Leave node list—the leave nodes of the shortest path tree in eachsearch direction are linked up in a double linked list which is sortedby the values of node path cost and node path hops of each leave node.The Least cost leave node is at the head of the linked list. (forminimum cost path only).

[0043] least cost branch is defined as the branch starting from the rootnode to the least cost leave node. (for minimum cost path only).

[0044] Candidate shortest path—a path that connects source node todestination node, and it is not more expensive than any other connectingpaths found so far. (for minimum cost path only).

Single Processor Environment

[0045] Midway Minimum Cost Path Search Algorithm for SINGLE PROCESSORSYSTEM Function Name: Midway_min_cost_sp

[0046] Description: To find a minimum cost path from a single sourcenode to a single destination node. Search is processed from source anddestination alternatively. This function creates two minimum cost pathtrees, one starts from source node as root, and the other starts fromthe destination node. A minimum cost path is found when the minimum costpath from the source node meets that from the destination.

[0047] Input:

[0048] 1. Network topology map.

[0049] 2. source node and destination node.

[0050] 3. path requirement information should also be provided inpractical application, but it is omitted here.

[0051] Output:

[0052] 1. The minimum cost path.

[0053] 2. Total number of hops in the path.

[0054] 3. Total cost of the path.

[0055] The output information is only valid when return is SUCCESS.

[0056] Called by: routing module.

[0057] Return: SUCCESS or FAILURE;

[0058] Algorithm of Function Midway_min_cost_sp:

[0059] 1. Initialize two identical sets of data structures. One set forforward search, and the other for backward search. (see attached headerfile “midway.h”.)

[0060] Both the forward search tree structure and the backward searchtree structure are created in a global two dimentional array defined asstruct nodeTempInfo tree[2][MAXNODES+1] wherein MAXNODES equals to thetotal number of nodes in the network, and tree[0][j] is for forwardsearch, tree[1][j] for backward search. The second index “j” intree[i][j] is the node number of each node in the network. Each elementof the array is a structure (struct nodeTempInfo) which contains fieldsof parent node number, node path cost and node path hops. Initialize theforward search tree structure by setting source node as its root as wellas its only leave node, that is to set fields oftree[0][srcNode].parentNode equal to source node, node path cost andnode path hops equal to “0”. Initialize the backward search treestructure by setting destination node as its root as well as its onlyleave node, that is to set fields of tree[1][destNode].parentNode equalto destination node, node path cost and node path hops equal to “0”. Forthe rest elements in the array tree[i][j] initialize parent node to “0”,and node path cost as well as node path hops to INFINITY which is a verylarge number.

[0061] Initialize a global two dimentional array leave node list whichis defined as struct node leaveCost[2][MAXNODES+1] to hold all leavenodes of the two search trees wherein leaveCost[0][j] is for leave nodeson forward search tree, and leaveCost[1][j] for those on backward searchtree. The second index “j” in leaveCost[i][j] is the node number of eachnode in the network. Each element leaveCost[i][j] is a structure (structnode) which contains fields of prev and next. “prev” is the node aheadof node j in the sorted list, and “next” is the node behind node j inthe sorted list. Initialize forward leave node list (leaveCost[0][ ]) bysetting source node as the only leave node in the list, and initializebackward leave node list (leaveCost[1][ ]) by setting destination nodeas the only leave node in the list.

[0062] Declare a global data structure “struct meet_node meetNode”, withfields “node” to hold the meet node number, “total_path cost” to holdthe candidate shortest path total path cost, and “total_path hops” tohold the candidate path total path hops. Initialize node equal to “0”,“total_path_cost” and “total_path_hops” to INFINITY.

[0063] 2. Initialize global variable “Direction” equal to FORWARD (i.e.to start search from the source node first).

[0064] 3. Entry of loop to build minimum cost path tree from source ordestination node. Set pointers pointing to the appropriate set of datastructures depending on search direction being FORWARD or BACKWARD.

[0065] 4. Set the least cost leave node on the current search directiontree as the searching node.

[0066] 5. Pick the first neighbor node in neighbor node list of thesearching node, and set the said neighbor node as searched node.

[0067] 6. Entry of loop to Search all neighbor nodes of the searchingnode. If the said searched node is the parent node of searching node onthe current search direction tree, skip this node and go to step 17,otherwise go to next step.

[0068] 7. Calculate new node path cost by adding node path cost of thesearching node and the link cost from searching node to the searchednode. Calculate new node path hops by adding 1 to node path hops ofsearching node.

[0069] 8. If the said searched node is already a leave on the currentsearch direction tree go to next step, otherwise go to step 10.

[0070] 9. Compare current node path parameters of the said searched nodewith new path parameters. If current searched node path is moreexpensive than new path go to next step, otherwise leave the saidsearched node as is and go to step 17.

[0071] 10. Now process the said searched node. Initialize or update itspath parameters by setting searched node path cost equal to new nodepath cost, and searched node path hops equal to new node path hops.

[0072] 11. If the said searched node is also a node on the oppositesearch direction tree (i.e. this is the meet node of a path linking thesource node and destination node), go to next step, otherwise go to step15.

[0073] 12. The path linking the two end nodes as mentioned in step 11 isgiven by concatenating the path from the source node to the meet nodeand the path from the destination node to the meet node. Calculate thenew total path cost by adding the node path cost of the said meet nodeon the current search direction tree and its node path cost on theopposite search direction tree. Calculate the new total path hops byadding the node path hops of the said meet node on the current searchdirection tree and its node path hops on the opposite search directiontree. Go to next step.

[0074] 13. If there exists a candidate shortest path go to next step,otherwise set the said path as the candidate shortest path by settingmeetNode.node equal to the said meet node, meetNode.total_path_costequal to new total path cost and meetNode.total_path_hops equal to newtotal path hops, and then go to step 15.

[0075] 14. Reaching this step a candidate shortest path is existing.Compare the new path parameters with candidate path parameters. Ifcandidate path is more expensive than new path, set new path ascandidate shortest path, and update candidate path parameters by settingmeetNode.node equal to the meet node on the new path,meetNode.total_path_cost equal to new total path cost andmeetNode.total_path_hops equal to new total path hops, otherwise leavethe existing candidate path as is.

[0076] 15. If the said searched node is not on the current searchdirection tree, attach it to the said tree as a new leave node byattaching it to the link from the searching node (i.e. set its parentnode equal to searching node), and insert it into the leave node list atan appropriate position determined by its node path parameters, then goto step 17. Otherwise go to next step.

[0077] 16. If the said searched node is already on the current searchdirection tree, remove it from the said tree and attach it back to thetree by linking it to the searching node. In addition to that since itsnode path cost and node path hops on the current search direction treehave been reduced in step 10, readjust its position in the leave nodelist if its node path is less expensive than the node path of the leavenode preceding it in the said list.

[0078] 17. Get next neighbor node of the searching node. If there is nomore next neighbor node go to next step, otherwise set searched nodeequal to next neighbor node and loop back to step 6.

[0079] 18. All neighbor nodes of the searching node have been processed.Remove the searching node from the leave node list as it now becomes abranch node in the tree. Set next searching node equal to the least costleave node on the updated current search direction tree. If nextsearching node is a valid node number, go to next step, otherwise returnFAILURE because it means that source node and destination node are notconnected.

[0080] 19. Reaching this step the next searching node is valid. IfmeetNode.node equals “0”, go to next step, otherwise meetNode.node isvalid which means there exists a candidate shortest path. Then check thecandidate shortest path to determine if it satisfies the condition of aqualified minimum cost path. First it needs to calculate the total pathcost of a virtual minimum cost path by adding the path cost of the leastcost branch on the forward search tree and the path cost of the leastcost branch on the backward search tree, and also to calculate the totalpath hops of a virtual minimum cost path by adding the path hops of thetwo least cost branches on the two above mentioned shortest path trees.Next compare the path parameters (i.e. path cost and path hops) of thevirtual minimum cost path with those of the candidate shortest path. Ifat this moment the candidate shortest path is not more expensive thanthe virtual minimum cost path, the candidate shortest path is identifiedto be the qualified minimum cost path. If the above stated condition isTRUE, search is done, return SUCCESS otherwise go to next step.

[0081] 20. Reaching this step there is no candidate shortest path or thecondition stated in step 19 is not TRUE, switch search direction (i.e.switch search direction from FORWARD to BACKWARD or vice versa) and loopback to step 3 to continue search.

[0082] PROOF of the condition defined in step 19 to determine a minimumcost path is found:

[0083] When the condition defined in step 19 is true, the least costleave node either on current search direction tree or on opposite searchdirection tree may or may not lie on a path connecting source node anddestination node. If it does, the said connecting path must be equallyexpensive as or more expensive than the candidate shortest path. If itdoes not lie on any connecting path, it will reach one of the leavenodes on the opposite search direction tree in the subsequent rounds ofsearch, and the connecting path thus created must be more expensive thanthat of the candidate shortest path. By exhausting all possible cases itcan be concluded that there is no possibility to find a connecting pathwhich is less expensive than the candidate shortest path.

[0084] Midway Minimum Hop Path Search Algorithm for SINGLE PROCESSORSYSTEM Function Name: Midway_min_hop_sp

[0085] Description: To find a minimum hop path from a single source nodeto a single destination node. Minimum hop path search function runs pathsearch code from source or destination node alternatively depending onthe value of search direction.

[0086] Conditions to determine a minimum hop path being found in forwardsearch direction:

[0087] 1. forward search path meets destination node.

[0088] 2. forward search path meets backward search path.

[0089] Conditions to determine a minimum hop path being found inbackward search direction:

[0090] 1. backward search path meets source node.

[0091] 2. backward search path meets forward search path.

[0092] Input:

[0093] 1. network topology map.

[0094] 2. source node, destination node.

[0095] 3. requirements of link capabilities should also be provided inpractical application, but omitted here.

[0096] Output:

[0097] 1. the minimum hop path.

[0098] 2. the total number of hops in the path.

[0099] The returned information is valid only if return value isSUCCESS.

[0100] Called by: routing module.

[0101] Return: SUCCESS or FAILURE

[0102] Algorithm of Function Midway_min_hop_sp:

[0103] 1. Create and Initialize two identical sets of data structures,one set for forward direction search and the other for backwarddirection search. (see header file midway.h).

[0104] Both the forward search tree and the backward search tree areexactly the same as those described in step 1 of algorithmMidway_min_cost_sp.

[0105] For each search direction create two identical lists, one issearching node list to hold all searching nodes in each search directionand the other is searched node list to hold the nodes being searched bythe searching nodes. Initialize source node as the only searching nodein the forward searching node list and initialize destination node asthe only searching node in the backward searching node list (see arraysleaveHop_(—)0[ ][ ], leaveHop_(—)1[ ][ ] in midway.h).

[0106] Set global variable Direction equal to FORWARD (i.e. to startsearch from the source node first).

[0107] Initialize global variables “hops[0]” and “hops[1]” to “0” where“hops[0]” is the total hops of the forward minimum hop path, and“hops[1]” is the total hops of the backward minimum hop path.

[0108] 2. Entry of the loop to build minimum hop path trees from sourcenode or destination node alternatively. Set pointers pointing toappropriate set of data structures depending on current search directionbeing FORWARD or BACKWARD. If this is not the first time entering thisloop, swap the pointers to searching node list and searched node list,so the searched nodes in the previous round become searching nodes inthe current round, and the searching node list used in the previousround is ready to hold the searched nodes in the current round.

[0109] 3. If searching node list is empty return FAILURE which meansthat source node and destination node are not connected, otherwise setsearching node equal to the first element in searching node list, and goto next step.

[0110] 4. Entry of the loop to process all nodes in the searching nodelist. Set searched node equal to the first neighbor node in the neighbornode list of the current searching node.

[0111] 5. Entry of the loop to search all neighbor nodes of a searchingnode. If the searched node is already on the current search directiontree, skip this node and go to step 10, otherwise go to next step.

[0112] 6. Process the said searched node. Attach it on the currentsearch direction tree by linking it to the searching node (i.e. set itsparent node in the current search direction tree equal to searchingnode).

[0113] 7. If searched node equals target node (inforward searchdirection target node is destination node, and in backward searchdirection target node is source node) or if searched node is a leavenode on the opposite search direction tree, this means that the searchednode is the meet node on the wanted minimum hop path and go to nextstep, otherwise go to step 9.

[0114] 8. Increase the current search direction path hops by 1, theminimum hop path found in step 7 is given by concatenating the path fromthe source node to the meet node and the path from the meet node to thedestination node, and the total path hops of the said minimum hop pathis given by adding the forward direction hops and backward directionhops. Return SUCCESS.

[0115] 9. Attach searched node to the tail of the searched node list,and go to next step.

[0116] 10. If the neighbor node list of the searching node is exhausted,go to next step, otherwise set searched node equal to the next neighbornode of the searching node, and loop back to step 5.

[0117] 11. All neighbor nodes of the current searching node have beensearched. Check the searching node list. If searching node list isexhausted, go to next step, otherwise set searching node equal to nextnode in the searching node list, and loop back to step 4.

[0118] 12. Current searching node list is exhausted, switch searchdirection (switch search direction from FORWARD to BACKWARD or viceversa), increase current search direction path hops by 1, and loop backto step 2.

Multi-Processor Environment

[0119] In multi-processor environment it is possible to take advantageof the power of parallel processing provided by multi-threading ormulti-tasking to further reduce shortest path set up time. A methodbased on multi-threading is described in the following. If the operatingsystem does not support multi-threading, multi-tasking is the secondchoice. The method based on multi-tasking should be very similar to thatbased on multi-threading and its description will not be given. Threadmanagement, scheduling and synchronization (shared resources integrityprotection) should be compliant to POSIX standard [5] and certainextensions supported by the operating system in use may also be adopted.

[0120] The process which runs the routing module code should do thefollowing to create a Parallel Processing Environment. (All threadsynchronization mechanisms mutexes, read write locks and conditionvariables created by routing process are process private objects.)

[0121] 1. The Boss-Worker parallel programming model is applied toimplement the shortest path search algorithm [6]. The routing processcreates a boss thread to run the main routing module, and creates twoworker threads to run the forward and backward shortest path searchfunctions.

[0122] 2. The worker thread creation function pthread_create( ) passes athread argument “int Direction” to the created thread. Direction isassigned FORWARD to one worker thread and BACKWARD to the other one. Theworker thread with Direction FORWARD will create a forward search treerooted at source node (i.e. the host node), while the worker thread withDirection BACKWARD will create a backward search tree rooted at thedestination node which is to be assigned by the boss thread case bycase.

[0123] 3. Choose system scheduling contention scope to bind the twoworker threads to two kernel threads in a one to one map, and make surethey will run on two distinct processors to guarantee parallelism.

[0124] 4. As shortest path searching is a real time job, the schedulingpolicy of the two worker threads should be SCHED_FIFO and their priorityshould be set to highest priority, so that they will be scheduled to runas soon as they get work and will not be preempted before the work isdone. (If 3 and 4 are not supported by the operating system, otherscheduling policy may be considered, but performance will be degraded.)

[0125] 5. Create mutexes or read write locks to protect shared data ordata structures which are listed below (see header file midway.h).

[0126] “struct nodeTempInfo tree[2][MAXNODES+1]” in which forward searchtree and backward search tree are created. (for both minimum cost andminimum hop path).

[0127] “struct meet_node meetNode” (for minimum cost path).

[0128] “unsigned short meetNode” (for minimum hop path).

[0129] “unsigned short totPathHops” (for minimum hop path).

[0130] 6. Initialize condition variables condForward, condBackward andcondboss and declare condition predicates searchForward, searchBackwardand searchDone to coordinate synchronization between boss thread and itsworker threads. Each condition predicate should be protected by itsassociated mutex.

[0131] 7. Define two user defined signal types SIGUSR1 and SIGUSR2 forinter-thread communication between two worker threads running inparallel to search for a shortest path from two opposite ends (sourceand destination). When one thread has found a shortest path, it willsend a signal to the other thread notifying it to stop search. SIGUSR1is to be sent to forward search worker thread by backward worker searchthread, and SIGUSR2 is to be sent in the other way round. All threads inrouting process should block the two user defined signal types exceptthe two said worker threads. The forward search worker thread shouldaccept SIGUSR1 and the backward search work thread should acceptSIGUSR2. Install two signal handlers in signal structures (structsigaction act1, act2;). Set act1.sa_handler equal to function pointersig_handler1 and act2.sa_handler equal to function pointer sig_handler2.Algorithm of Signal handlers will be given following the description forfunction Min_cost_search.

[0132] 8. Declare global array flagDone[2]. It is initialized to allzeros by function Midway_min_cost_mp or Midway_min_hop_mp. WhenflagDone[0] is set to “1” (TRUE), it is to notify forward search threadto stop search. When flagDone[1] is set to “1” (TRUE), it is to notifybackward search thread to stop search. Array flagDone[2] is not a sharedobject. “flagDone[i]” is updated by sig_handler.

[0133] 9. Whenever routing module needs to find a shortest path from thesource node (i.e. the host node) to a destination node, it callsfunction Midway_min_cost_mp for minimum cost path or functionMidway_min_hop_mp for minimum hop path. Either function being calledwill initialize working data structures and global variables in theprocess heap space to be used by the two worker threads and wake up theworker threads by signaling a condition variable.

[0134] 10. Worker threads also need to access the structure of networktopology map. As the access is “read only”, it doesn't need threadsynchronization. The boss thread is responsible for updating the networktopology map, but the structure should be kept frozen while shortestpath search is in progress, so there is no concurrent access conflict inthis structure.

[0135] Midway Minimum Cost Path Search Algorithm for MULTI-PROCESSORSYSTEM

[0136] The algorithm of boss thread function Midway_min_cost_mp and thatof worker thread function Min_cost_search are described below.

[0137] Function Name: Midway_min_cost_mp

[0138] Description: To find a minimum cost path from a single sourcenode to a single destination node. Search is processed from source anddestination simultaneously. This function activates two threads tocreate two minimum cost path trees, one starts from source node as root,and the other starts from the destination node as root. A minimum costpath is found when two minimum cost paths meet.

[0139] Input:

[0140] 1. Network topology map.

[0141] 2. source node and destination node.

[0142] 3. path requirement information should also be provided inpractical application, but it is omitted here.

[0143] Output:

[0144] 1. The minimum cost path

[0145] 2. Total number of hops in the path

[0146] 3. Total cost of the path.

[0147] The output information is only valid when return is SUCCESS.

[0148] Called by routing module.

[0149] Running in boss thread.

[0150] Return: SUCCESS or FAILURE;

[0151] Algorithm of Function Midway_min_cost_mp:

[0152] 1. Initialize global data structures in the process heap space.

[0153] The forward search tree and backward search tree in array tree[][ ] are same as those described in step 1 of functionMidway_min_cost_sp. As they are shared objects the two path searchworker threads should lock the mutex for each tree before access it, andunlock the mutex after work is done. If the operating system providesread write lock mechanism it can be used to replace mutex, so the saidtwo threads may share read a search tree, and exclusive access mode isonly required when a thread needs write access.

[0154] The leave node lists in array leaveCost[ ][ ] are same as thosedescribed in step 1 of function Midway_min_cost_sp. As they are notshared objects, so there is no need to consider thread synchronization.

[0155] Structure “struct meet_node meetNode” is same as that describedin Midway_min_cost_sp. It is a shared object and should be protected bya mutex or read write lock.

[0156] Initialize condition variables condForward, condbackward andcondboss and condition predicates searchForward, searchbackward andsearchDone. Each condition predicate should be protected by its ownassociated mutex.

[0157] Zero out array flagDone[2].

[0158] Thread synchronization should be applied to access shared dataand data structures. The lock and unlock operations will not beexplicitly stated in the description of the algorithm to make thedescription more readable, but they should be implemented in the code.

[0159] 2. Wake up forward search thread by setting predicatesearchForward equal to TRUE and signaling condition variablecondForward, and wake up backward search thread by setting predicatesearchBackward equal to TRUE and signaling condBackward.

[0160] 3. Wait on condition variable condBoss, till the shortest path isfound by the worker threads.

[0161] 4. When one of the worker threads succeeds in finding a shortestpath or fails, it will set its return value to SUCCESS or FAILURE, setpredicate searchDone equal to TRUE and signal condboss to wake up bossthread. The boss thread being activated will set predicate searchDone toFALSE and continue to run.

[0162] 5. Check the return value in heap space. If it is SUCCESS, returnthe shortest path in the format of a list of nodes and the total pathcost and total path hops of the path to the calling function in routingmodule, otherwise return FAILURE. The way to get the result shortestpath is to concatenate the path from the source node to the meet nodeindicated by meetNode.node and the path from the said meet node to thedestination node. “total path cost” and “total path hops” are given bymeetNode.total_path_cost and meetNode.total_path_hops.

[0163] Function Name: Min_cost_search

[0164] Description: It creates a shortest path tree from a root node(source or destination node as the case may be). A minimum cost path isfound when the shortest path created by it meets that from the oppositeend node.

[0165] Input:

[0166] 1. Network topology map.

[0167] 2. source node and destination node.

[0168] 3. path requirement information should also be provided inpractical application, but it is omitted here.

[0169] Output:

[0170] 1. The minimum cost path

[0171] 2. Total number of hops in the path

[0172] 3. Total cost of the path.

[0173] The output information is only valid when return is SUCCESS.

[0174] Activated by function Midway_min_cost_mp.

[0175] Running in worker thread.

[0176] Return: SUCCESS or FAILURE;

[0177] Algorithm of Function Min_cost_search:

[0178] 1. Entry of loop to wait for work. Wait on condition variablecondForward or condbackward depending on argument Direction beingFORWARD or BACKWARD which is passed to it by thread creation function.When boss thread function Midway min cost mp signals the said conditionvariable, the worker thread is scheduled to run, and start to do work.

[0179] 2. Set pointers pointing to the appropriate set of datastructures depending on argument “Direction” being FORWARD or BACKWARD.The source node is always the host node, and the value of destinationnode is initialized as the root node in the backward search treestructure by function Midway_min_cost_mp.

[0180] 3. Set the root node of current search direction tree as thesearching node.

[0181] 4. Entry of loop to build minimum cost path tree from root node.Pick the first neighbor node in neighbor node list of the searching nodeby accessing the network topology map, and set the said neighbor node assearched node.

[0182] 5. Entry of loop to Search all neighbor nodes of the searchingnode. If the said searched node is the parent node of searching node oncurrent search direction tree, skip this node and go to step 16,otherwise go to next step.

[0183] 6. Calculate new node path cost by adding node path cost of thesearching node and the link cost from searching node to the searchednode. Calculate new node path hops by adding 1 to node path hops ofsearching node.

[0184] 7. If the said searched node is already a leave on current searchdirection tree go to next step, otherwise go to step 9.

[0185] 8. Compare current node path parameters of the said searched nodewith new path parameters. If current searched node path is moreexpensive than new path go to next step, otherwise leave the saidsearched node as is and go to step 16.

[0186] 9. Now process the said searched node. Initialize or update itspath parameters by setting searched node path cost equal to new nodepath cost, and searched node path hops equal to new node path hops.

[0187] 10. If the said searched node is also a node on the oppositesearch direction tree (i.e. this is the meet node of a path linking thesource node and the destination node), go to next step, otherwise go tostep 14.

[0188] 11. The path linking the two end nodes found in step 10 is givenby concatenating the path from the source node to the meet node and thepath from the meet node to the destination node. Calculate the new totalpath cost by adding the node path cost of the said meet node on currentsearch direction tree and its node path cost on opposite searchdirection tree. Calculate the new total path hops by adding the nodepath hops of the said meet node on current search direction tree and itsnode path hops on opposite search direction tree. Go to next step.

[0189] 12. If meetNode.node is a valid node number which means thatthere exists a candidate shortest path, go to next step, otherwise Setthe new path found in step 10 as the candidate shortest path by settingmeetNode.node equal to meet node on the new path,meetNode.total_path_cost equal to new total path cost andmeetNode.total_path_hops equal to new total path hops. Then go to step14.

[0190] 13. Reaching this step a candidate shortest path exists. Comparethe new path parameters with path parameters of the candidate path. Ifcandidate path is more expensive than new path, set new path ascandidate shortest path by setting meetNode.node equal to meet node onthe new path, meetNode.total_path_cost equal to new total path cost,meetNode.total_path_hops equal to new total path hops, otherwise leavethe existing candidate path as is.

[0191] 14. If the said searched node is already on current searchdirection tree, go to next step, otherwise attach it to the said tree asa new leave node by attaching it to the link from the searching node(i.e. set its parent node equal to searching node). Insert the searchednode into the current search direction leave node list at an appropriateposition determined by its node path parameters, and then go to step 16.

[0192] 15. Reaching this step the said searched node is already oncurrent search direction tree. Remove it from the said tree and attachit back to the tree by linking it to the searching node. In addition tothat since its node path cost and node path hops on the current searchdirection tree have been reduced in step 9, readjust its position in theleave node list if its node path is less expensive than the node path ofthe leave node preceding it in the said list.

[0193] 16. Get next neighbor node of the searching node. If there is nomore next neighbor node go to next step, otherwise set searched nodeequal to next neighbor node and loop back to step 5.

[0194] 17. Reaching this step all neighbor nodes of the searching nodehave been processed. Now check out if the other worker thread has sentany signal by reading flagDone[Direction]. If the value read is TRUE, itmeans that search should stop, break out of the loop started at step 4,and loop back to step 1, otherwise continue search. Remove the searchingnode from the leave node list as it now becomes a branch node in thetree. Set next searching node equal to the least cost leave node on theupdated current search direction tree. If the next searching node is avalid node number, go to step 19, otherwise go to next step.

[0195] 18. Reaching this step search fails, as this condition means thesource node and destination node are not connected, set return value toFAILURE, signal the other worker thread to stop, set predicate searchDone to TRUE, signal condBoss to wake up boss thread, break out of theloop started from step 4 and loop back to step 1.

[0196] 19. Reaching this step the searching node is valid. IfmeetNode.node equals “0”, go to next step, otherwise meetNode.node isvalid which means there exists a candidate shortest path. Then check thecandidate shortest path to determine if it satisfies the condition of aqualified minimum cost path. First it needs to calculate the total pathcost of a virtual minimum cost path by adding the path cost of the leastcost branch on the forward search tree and the path cost of the leastcost branch on the backward search tree, and also to calculate the totalpath hops of a virtual minimum cost path by adding the path hops of thetwo least cost branches on the two above mentioned shortest path trees.Next compare the path parameters (i.e. path cost and path hops) of thevirtual minimum cost path with those of the candidate shortest path. Ifat this moment the candidate shortest path is not more expensive thanthe virtual minimum cost path, the candidate shortest path is identifiedto be the qualified minimum cost path. If the above stated condition isnot TRUE, go to next step, otherwise search is done, set return value toSUCCESS, send a signal to the other worker thread to notify it to stop,set predicate searchDone to TRUE and signal condboss to wake up bossthread, break out of the loop started at step 4, and loop back to step1.

[0197] 20. Reaching this step either candidate shortest path doesn'texist, or the condition stated in step 19 is not TRUE, loop back to step4 to continue search.

[0198] PROOF of the condition stated in step 19 is the same as the proofgiven in function Midway_min_cost_sp.

[0199] Function Name: sig_handler1

[0200] Description: To handle the signal of type SIGUSR1 being sent toforward search worker thread to notify the said thread to stop search.

[0201] Algorithm of Function sig_handler1

[0202] 1. set flagDone[0] equal to TRUE.

[0203] 2. return;

[0204] Function Name: sig_handler2

[0205] Description: To handle the signal of type SIGUSR2 being sent tobackward search worker thread to notify the said thread to stop search.

[0206] Algorithm of Function sig_handler2

[0207] 1. set flagDone[1] equal to TRUE.

[0208] 2. return;

[0209] Midway Minimum Hop Path Search Algorithm for MULTI-PROCESSORSYSTEM

[0210] Function Name: Midway_min_hop_mp

[0211] Description: To find a minimum hop path from a single source nodeto a single destination node. Search is processed from source anddestination simultaneously. This function activates two threads tocreate two minimum hop path trees, one starts from source node as root,and the other starts from the destination node as root.

[0212] Conditions to determine a minimum hop path being found in forwardsearch direction:

[0213] 3. forward search path meets destination node.

[0214] 4. forward search path meets backward search path.

[0215] Conditions to determine a minimum hop path being found inbackward search direction:

[0216] 3. backward search path meets source node.

[0217] 4. backward search path meets forward search path.

[0218] Input:

[0219] 1. network topology map.

[0220] 2. source node, destination node.

[0221] 3. requirements of link capabilities should also be provided inpractical application, but omitted here.

[0222] Output:

[0223] 1. the minimum hop path.

[0224] 2. the total number of hops in the path.

[0225] The returned information is valid only if return value isSUCCESS.

[0226] Called by routing module.

[0227] Running in boss thread.

[0228] Return: SUCCESS or FAILURE.

[0229] Algorithm of Function Midway_min_hop_mp:

[0230] 1. Initialize global data and data structures in the process heapspace. (see header file midway.h).

[0231] Initialization of the forward search tree and the backward searchtree in array tree[ ][ ] and thread synchronization mechanism areexactly the same as those described in step 1 of algorithmMidway_min_cost_mp.

[0232] Initialize global variable “unsigned short meetNode” to “0” whichis a shared object and should be protected by a mutex or a read writelock.

[0233] For each search direction initialize two identical lists, one issearching node list to hold all searching nodes in each search directionand the other is searched node list to hold the nodes being searched bythe searching nodes (see midway.h leaveHop_(—)0[ ][ ] and leaveHop_(—)1[][ ]). Initialize source node as the only searching node in the forwardsearching node list and initialize destination node as the onlysearching node in the backward searching node list. The searching nodelist and searched node list are not shared objects, so there is no needto consider synchronization to access them.

[0234] Zero out array “unsigned char hops[2]” where “hops[0]” is thetotal hops of the forward minimum hop path, and “hops[1]” is the totalhops of the backward minimum hop path. Array hops[2] is not a sharedobject and there is no need to consider concurrent access protection.

[0235] Initialize global variable “unsigned short totPathHops” equal to“INFINITY”. It is not a shared object.

[0236] Initialize condition variables condForward, condbackward andcondBoss which are not shared objects. Initialize condition predicatessearchForward, searchbackward and searchDone which are shared objectsand should be protected by their associated mutexes. Both conditionvariables and condition predicates are used to coordinatesynchronization between boss thread and its two worker threads.

[0237] Zero out global array flagDone[2]. This array is not a sharedobject.

[0238] Thread synchronization should be applied to access shared dataand data structures. The lock and unlock operations will not beexplicitly stated in the description of the algorithm to make thedescription more readable, but they should be implemented in the code.

[0239] 2. Wake up forward search thread by setting predicatesearchForward to TRUE and signaling condition variable condForward, andwake up backward search thread by setting predicate searchBackward toTRUE and signaling condBackward.

[0240] 3. Wait on condition variable condBoss, till the shortest path isfound by the worker threads.

[0241] 4. When one of the worker threads succeeds in finding a shortestpath or fails, it will set its return value to SUCCESS or FAILURE, setpredicate searchDone to TRUE and signal condBoss to wake up boss thread.The boss thread will set predicate searchDone to FALSE and continue torun.

[0242] 5. Check the return value in heap space. If it is SUCCESS, returnthe shortest path in the format of a list of nodes and the total pathhops of the shortest path to the calling function in routing module,otherwise return FAILURE. The way to get the result shortest path is toconcatenate the path from the source node to the meet node given bymeetNode and the path from the said meet node to the destination node.“total path hops” is given by adding hops[0] and hops[1].

[0243] Function Name: Min_hop_search

[0244] Description: It creates a shortest path tree from a root node(source or destination node as the case may be). A minimum hop path isfound when the shortest path created by it meets that from the oppositeend node.

[0245] Input:

[0246] 1. Network topology map.

[0247] 2. source node and destination node.

[0248] 3. path requirement information should also be provided inpractical application, but it is omitted here.

[0249] Output:

[0250] 1. the meet node number given by meetNode.

[0251] 2. hops[0] and hops[1].

[0252] The output information is only valid when return is SUCCESS.

[0253] Activated by function Midway_min_hop_mp.

[0254] Running in worker thread.

[0255] Return: SUCCESS or FAILURE;

[0256] Algorithm of Function_Min_hop search:

[0257] 1. Entry of loop to wait for work. Wait on condition variablecondForward or condBackward depending on argument Direction beingFORWARD or BACKWARD which is passed to it by thread creation function.When boss thread function Midway_min_hop_mp signals the said conditionvariable, the worker thread is activated. It should set predicatesearchForward or searchBackward to FALSE and start to do work. Setpointers pointing to the appropriate set of data structures depending onargument “Direction” being FORWARD or BACKWARD. The source node isalways the host node, and the value of destination node is initializedas the root node in the backward search tree by functionMidway_min_hop_mp.

[0258] 2. Entry of loop to build minimum hop path tree from source nodeor destination node. If this is not the first time entering this loop,swap the pointers to searching node list and searched node list, so thesearched nodes in the previous round become searching nodes in thecurrent round, and the searching node list used in the previous round isready to hold the searched nodes in the current round.

[0259] 3. If searching node list is empty, it means that source node anddestination node are not connected, set return value to FAILURE, sendsignal to notify the other worker thread to stop, set conditionpredicate “searchDone” to TRUE and signal condBoss to wake up bossthread, break out of the loop started from step 2, and loop back tostep 1. If searching node list is not empty set searching node equal tothe first element in searching node list, and go to next step.

[0260] 4. Entry of the loop to process all nodes in the searching nodelist. Set searched node equal to the first neighbor node in the neighbornode list of the current searching node.

[0261] 5. Entry of the loop to search all neighbor nodes of a searchingnode. If the searched node is already on the current search directiontree, skip this node and go to step 10, otherwise go to next step.

[0262] 6. Process the said searched node. Attach it on the currentsearch direction tree by linking it to the searching node (i.e. set itsparent node in the current search direction tree equal to searchingnode).

[0263] 7. If searched node equals target node (inforward searchdirection target node is destination node, and in backward searchdirection target node is source node) or if searched node is a leavenode on the opposite search direction tree, this means that the searchednode is the meet node on the wanted minimum hop path and go to nextstep, otherwise go to step 9.

[0264] 8. Reaching this step the minimum hop path is found. Now firstcheck if the other worker thread has sent any signal by readingflagDone[Direction]. If the value read is TRUE, it means that this is anotification to stop search, break out of the loop started from step 2,and loop back to step 1, otherwise report search done. Set sharedvariable meetNode equal to the meet node mentioned in step 7. Increasethe current search direction path hops by 1 (i.e. increasehops[Direction] by 1). Set return value equal to SUCCESS. Send a signalto the other worker thread to notify it to stop search. Set conditionpredicate searchDone to TRUE and signal condition variable condBoss towake up boss thread. Break out of the loop started at step 2, and loopback to step 1.

[0265] 9. Attach searched node to the tail of the searched node list,and go to next step.

[0266] 10. If the neighbor node list of the searching node is exhausted,go to next step, otherwise set searched node equal to the next neighbornode of the searching node, and loop back to step 5.

[0267] 11. All neighbor nodes of the current searching node have beensearched. Now check if the other worker thread has sent any signal byreading flagDone[Direction]. If the value read is TRUE, it means thatthis is a notification to stop search, break out of the loop startedfrom step 2, and loop back to step 1, otherwise continue to search.Check the searching node list. If searching node list is exhausted, goto next step, otherwise set searching node equal to next node in thesearching node list, and loop back to step 4.

[0268] 12. Current searching node list is exhausted, increase currentsearch direction path hops by 1 (i.e. increase hops[Direction] by 1),and loop back to step 2.

[0269] Notice:

[0270] While this invention has been described with reference toillustrative embodiments, this description is not intended to beconstrued in a limiting sense. Various modifications of the illustrativeembodiments, as well as other embodiments of the invention, which areapparent to persons skilled in the art to which the invention pertainsare deemed to lie within the spirit and scope of the invention.

What I claim as my invention is:
 1. A method to search for a shortestpath (i.e. minimum hop path or minimum cost path) from a single sourcenode to a single destination node in a two dimensional computer networkby doing shortest path search from both source node and destination nodealternatively or simultaneously, and the shortest path is found when ashortest path from one end node meets a shortest path from the other endnode at an intermediate node on midway, and the concatenated pathsatisfies a certain condition.
 2. A method to do shortest path searchfrom source and destination nodes alternatively in a single task and asingle function for the purpose of implementing the method as set forthin claim
 1. 2-a. The method as set forth in claim 2 is implemented bydeclaring two identical sets of data structures, one for search fromsource node and the other for search from destination node, and byswapping pointers to one set of structures from the other after eachround of shortest path search is done, so the same code executed in thesaid round will do shortest path search from the two opposite end nodesalternatively. 2-b. The code in each round of shortest path searchbuilds a shortest path tree similar to what Dijkstra algorithm does.2-c. For minimum hop path search, one round of shortest path search asmentioned in 2.a and 2-b is defined as the search process exhausting allleave nodes of the minimum hop path tree in the current searchdirection. 2-d. For minimum cost path search, one round of shortest pathsearch as mentioned in 2.a and 2-b is defined as the search processexhausting all neighbor nodes of the leave node with least path costfrom the root of the minimum cost path tree in the current searchdirection. 2-e. The leave nodes created in each round of minimum costpath search as defined in 2-d is inserted into a double linked listwhich is sorted by the path cost and path hops from each leave node tothe root node, so the leave node at the head of the sorted list is readyfor use in the next round of search.
 3. A method to determine whether ashortest path (a minimum hop path or a minimum cost path as the case maybe) is successfully found for the purpose of implementing the method asset forth in claim
 1. 3-a. The method as set forth in claim 3 forminimum hop path search is defined as that a leave node on the shortestpath tree from one end node (i.e. source or destination node) meets aleave node of the shortest path tree from the other end node, and thiscondition implies the special case of a leave node of the shortest pathtree from one end node meeting the opposite end node which only happenswhen source and destination are adjacent nodes. 3-b. The method as setforth in claim 3 for minimum cost path search is defined as follows.3-b-1. To make this claim more readable the following terms andstatements are defined. The statement “path A being less expensive thanpath B” is defined as that the total cost of links in path A is lessthan that in path B, or the total hops in path A is less than that inpath B when path costs in both paths are equal. The statement “path A ismore expensive than path B” is defined as that the total cost of linksin path A is greater than that in path B, or total hops in path A isgreater than that in path B when total costs in both paths are equal.Least cost leave node is a leave node whose path to the root node is notmore expensive than the path of any other leave node to the root. leastcost branch is defined as the branch starting from the root node to theleast cost leave node. 3-b-2. When a least cost branch on the shortestpath tree rooted at one end node (i.e. source or destination node) meetsany leave node on the shortest path tree rooted at the opposite endnode, it makes a path connecting the two end nodes, and if this is thefirst path found connecting the two end nodes, make it a candidateminimum cost path. 3-b-3. The node at which the two said shortest pathtrees meet is defined as the meet node. 3-b-4. When a subsequent pathconnecting source node and destination node is found, compare the saidpath with the existing candidate minimum cost path, and pick the lessexpensive path as the candidate minimum cost path. 3-b-5. After eachround of minimum cost path search as defined in 2-d is completed and ifthere exists a candidate minimum cost path at this moment, check thesaid candidate path to determine if it qualifies the condition of aminimum cost path. 3-b-6. To define the condition to be met by aqualified minimum cost path it needs to calculate the total path cost ofa virtual minimum cost path by adding the path cost of the least costbranch on the shortest path tree rooted at source node and the path costof the least cost branch on the shortest path tree rooted at thedestination node, and also to calculate the total path hops of a virtualminimum cost path by adding the total hops of the two least costbranches on the above mentioned two shortest path trees. 3-b-7. Aftervirtual minimum cost path parameters calculation is done, compare thepath parameters (i.e. path cost and path hops) of the virtual minimumcost path with those of the candidate minimum cost path. 3-b-8. If atthe moment mentioned in 3-b-5 the candidate minimum cost path is notmore expensive than the virtual minimum cost path, the candidate path isidentified to be the qualified minimum cost path.
 4. A method is definedin the following to do shortest path search from source and destinationnodes simultaneously by taking advantage of the power of parallelprocessing provided by multi-threading or multi-tasking in amulti-processor environment for the purpose of implementing the methodas set forth in claim
 1. 4-a. A Boss-Worker parallel programming modelis adopted to implement the method as set forth in claim 4, and thisimplies that a routing process creates a boss thread to run the mainrouting function, and the boss thread creates two worker threads to runthe forward and backward shortest path search functions. 4-b. The twoworker threads mentioned in 4-a should run in parallel on two separateprocessors, and the thread scheduling policy should allow the two workerthreads to run as soon as they get a shortest path search job, and notto be preempted till the job is completed. 4-c. Each worker thread runsa shortest path search function similar to Dijkstra algorithm whichcreates a shortest path tree rooted at the source node or at thedestination node depending on the search direction of the worker thread.4-d. For minimum cost path search the leave nodes created in each roundof minimum cost path search as defined in 2-d is inserted into a doublelinked list which is sorted by the path cost and path hops from eachleave node to the root node, so the leave node at the head of the sortedlist is ready for use in the next round of search. 4-e. A shortest pathis found when one shortest path on the tree rooted at one end node (i.e.source or destination node) meets another shortest path on the treerooted at the other end node, and the concatenated path from source nodeto destination node satisfies the condition defined in claim 3 whereincondition for minimum cost path and that for minimum hop path aredifferent. 4-f The boss thread defined in 4-a creates and initializesglobal variables and data structures required by the two worker threadsdefined in 4-a to run shortest path search function, and some of themare shared objects, so boss thread should create mutexes or read writelocks to synchronize concurrent access to those shared objects. 4-g. Thesaid boss thread creates condition predicates, condition variables andtheir associated mutexes to coordinate synchronization between bossthread and the two worker threads which implies that the boss threaduses one set of condition predicate and variable to wake up a workerthread while it is waiting for job, and a worker thread uses another setof condition predicate and variable to wake up the boss thread while itis waiting for the job to be done. 4-h. The said boss thread defines twouser defined signals SIGUSR1 and SIGUSR2 and installs signal handlersfor the two said signals which are used by the two worker threads forinter-thread communication purpose. 4-i. The two worker threads stay inwait state waiting for job, and when the boss thread needs to find ashortest path, it wakes up each worker thread by signaling its conditionpredicate and variable, so the worker threads will start to run theshortest path search function. 4-j. When one worker thread has found ashortest path it signals the other worker thread to stop searching bySIGUSR1 or SIGUSR2, and signals the boss thread by condition predicateand variable to wake up boss thread to process the result of shortestpath search. 4-k. All thread management, scheduling and synchronizationmechanisms are compliant to POSIX standard, and some extensions may alsobe used if supported by the operating system. 4-l. If multi-threading isnot supported by operating system, multi-tasking is the second choice,and its implementation is very similar to the method defined in claim 4in principle.